package com.example.xViewChat.NettyClient;

import android.content.Context;

/**
 * Created by hasee on 2016-04-01.
 * <p/>
 * SharedPreferences
 */
public class CacheTools {
    public static String CONFIG_INFO = "CONFIG_INFO";

    public static String KEY_ACCOUNT = "KEY_ACCOUNT";

    public static String KEY_MANUAL_STOP = "KEY_MANUAL_STOP";

    public static String KEY_DESTORYED = "KEY_DESTORYED";

    public static String KEY_SERVIER_HOST = "KEY_SERVIER_HOST";

    public static String KEY_SERVIER_PORT = "KEY_SERVIER_PORT";

    public static String KEY_AUTO_RECONNECT = "KEY_AUTO_RECONNECT";


    public static void putString(Context context, String key, String value) {
        context.getSharedPreferences(CONFIG_INFO, Context.MODE_PRIVATE).edit().putString(key, value).commit();
    }

    public static String getString(Context context, String key) {
        return context.getSharedPreferences(CONFIG_INFO, Context.MODE_PRIVATE).getString(key, null);
    }

    public static void putBoolean(Context context, String key, boolean value) {
        context.getSharedPreferences(CONFIG_INFO, Context.MODE_PRIVATE).edit().putBoolean(key, value).commit();
    }

    public static boolean getBoolean(Context context, String key) {
        return context.getSharedPreferences(CONFIG_INFO, Context.MODE_PRIVATE).getBoolean(key, false);
    }


    public static void putInt(Context context, String key, int value) {
        context.getSharedPreferences(CONFIG_INFO, Context.MODE_PRIVATE).edit().putInt(key, value).commit();
    }

    public static int getInt(Context context, String key) {
        return context.getSharedPreferences(CONFIG_INFO, Context.MODE_PRIVATE).getInt(key, 0);
    }
}
